<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <body>

        <ui:composition template="./template.xhtml">            
            <ui:define name="navigation">
                <ui:include src="menu.xhtml">
                    <ui:param name="select" value="#{2}"/>
                </ui:include>
            </ui:define>
            <ui:define name="content">
                <h1>
                    <h:outputText value="#{bundle.AUsers}" />
                </h1>
                <h:dataTable value="#{usersBean.users}" var="u"
                             styleClass="order-table"
                             headerClass="order-table-header"
                             rowClasses="order-table-odd-row,order-table-even-row">
                    <h:column>
                        <f:facet name="header">#{bundle.Ausername}</f:facet>
                        #{u.username}
                    </h:column>

                   <h:column>
                       <f:facet name="header">#{bundle.AFirstName}</f:facet>
                        #{u.firstName}
                    </h:column>

                    <h:column>
                        <f:facet name="header">#{bundle.ALastName}</f:facet>
                        #{u.lastName}
                    </h:column>
                    <h:column>
                        <f:facet name="header">#{bundle.AEmail}</f:facet>
                        #{u.email}
                    </h:column>
                    <h:column>
                        <f:facet name="header">#{bundle.AGroup}</f:facet>                        
                        <ui:repeat value="#{u.groupses.toArray()}" var="g">
                            <h:outputText value="#{g.groupName}"/>
                        </ui:repeat>
                        
                    </h:column>                                        
                    <h:column>
                        <f:facet name="header">#{bundle.MfEdit}</f:facet>
                        <h:link rendered="#{u.groupses.toArray()[0].groupName != 'ADMIN'}" styleClass="tableLink" value="#{bundle.MfEdit}" outcome="editUser" >
                             <f:param name="id" value="#{u.idusers}" />
                        </h:link>
                    </h:column>
                    <h:column>
                        <f:facet name="header">#{bundle.MfDelete}</f:facet>
                        <h:form>
                            <h:commandLink rendered="#{u.groupses.toArray()[0].groupName != 'ADMIN'}"
                                           styleClass="tableLink" value="#{bundle.MfDelete}"
                                           onclick="return confirm('#{bundle.MfConfirm}')"
                                           action="#{usersBean.delete(u.idusers)}"/>
                            
                        </h:form>
                    </h:column>
                    
                </h:dataTable>
            </ui:define>
        </ui:composition>
    </body>
</html>